package com.kaibes.module.log;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.kaibes.orm.core.core.Page;
import com.kaibes.orm.curd.Query;
import com.kaibes.orm.curd.QueryBuilder;
import com.kaibes.web.api.ResponseServiceImpl;

@Service
public class ApiLogService extends ResponseServiceImpl<ApiLog> {
    
    public Page<ApiLog> pageBySearch(int pageIndex, int pageSize, String search) {
        List<Query> queries = new ArrayList<>();
        queries.add(QueryBuilder.newBuilder().like("ip", search).build());
        queries.add(QueryBuilder.newBuilder().like("ip", search).build());
        queries.add(QueryBuilder.newBuilder().like("user_id", search).build());
        queries.add(QueryBuilder.newBuilder().like("url", search).build());
        queries.add(QueryBuilder.newBuilder().like("method", search).build());
        queries.add(QueryBuilder.newBuilder().like("status_code", search).build());
        queries.add(QueryBuilder.newBuilder().like("request_time", search).build());
        queries.add(QueryBuilder.newBuilder().like("response_time", search).build());
        return page(pageIndex, pageSize, queries);
    }
    
}
